package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.WorkerService;

public class AddWorkerController extends HttpServlet{
     WorkerService workerservice=new WorkerService();
	@Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	// TODO Auto-generated method stub
    	doPost(req, resp);
    }
      @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	// TODO Auto-generated method stub
    	req.setCharacterEncoding("utf8");
 		String wname=req.getParameter("wname");
 		String wage=String.valueOf(req.getParameter("wage"));
		int wages = 0;//任务状态
		if(wage!=null && !"".equals(wage) && !"null".equals(wage))
		   {
			wages=Integer.parseInt(wage);
		   }
 		String wsex=req.getParameter("wsex");
 		String wphone=req.getParameter("wphone");
 		String wadress=req.getParameter("wadress");
 		String did=String.valueOf(req.getParameter("did"));
		int dids = 0;//任务状态
		if(did!=null && !"".equals(did) && !"null".equals(did))
		   {
			dids=Integer.parseInt(did);
		   }
 		String dname=req.getParameter("dname");
 		String work_age=String.valueOf(req.getParameter("work_age"));
		int work_eges = 0;//任务状态
		if(work_age!=null && !"".equals(work_age) && !"null".equals(work_age))
		   {
			work_eges=Integer.parseInt(did);
		   }
 		resp.setCharacterEncoding("utf8");
 		PrintWriter pw=resp.getWriter();
 		pw.write(workerservice.addworker(wname, wages, wsex, wphone, wadress, dids, dname, work_eges).toString());
    }
}
